package com.best.onegous.viewutils;

import com.best.onegous.R;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.animation.Keyframe;

public class RedDialog {

	private Dialog mDialog;
	private TextView dialog_title;
	private TextView dialog_message;
	public TextView positive;
	public TextView negative;
	private RelativeLayout redbg;
	public RedDialog(Context context) {

		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.reddialog_layout, null);

		mDialog = new Dialog(context, R.style.dialogDim);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		redbg = (RelativeLayout) view.findViewById(R.id.redbg);
		//nope(redbg);
		Animation animation = AnimationUtils.loadAnimation(  
				context, R.anim.redanim);  
		redbg.startAnimation(animation);   
        /*mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if(keyCode==KeyEvent.KEYCODE_BACK){
                    return true;
                }
                return false;
            }
        });*/
		
		
	}
	
	public void show() {
		mDialog.show();
	}
	
	public void dismiss() {
		mDialog.dismiss();
	}
	public static ObjectAnimator nope(View view) {  
	    int delta = view.getResources().getDimensionPixelOffset(10);  
	   
	    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,  
	            Keyframe.ofFloat(0f, 0),  
	            Keyframe.ofFloat(.10f, -delta),  
	            Keyframe.ofFloat(.26f, delta),  
	            Keyframe.ofFloat(.42f, -delta),  
	            Keyframe.ofFloat(.58f, delta),  
	            Keyframe.ofFloat(.74f, -delta),  
	            Keyframe.ofFloat(.90f, delta),  
	            Keyframe.ofFloat(1f, 0f)  
	    );  
	   
	    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).  
	            setDuration(500);  }
}
